package com.ts.mark.service.impl;

import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ts.mark.entity.Mark;
import com.ts.mark.entity.Movie;
import com.ts.mark.mapper.MarkMapper;
import com.ts.mark.service.MarkService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;


@Service
@Slf4j
public class MarkServiceImpl extends ServiceImpl<MarkMapper, Mark> implements MarkService {

    @Override
    public List<Movie> mark(String userInfo) {
        Map map=JSON.parseObject(userInfo, Map.class);
        Integer userId=(Integer) map.get("userId");
        return baseMapper.mark(userId);
    }

    @Override
    public boolean add(Integer id, String userInfo) {
        Mark mark=new Mark();
        mark.setMsId(id);
        Map map=JSON.parseObject(userInfo, Map.class);
        mark.setUserid((Integer) map.get("userId"));
        return baseMapper.insert(mark)>0?true:false;
    }
}